package com.wavefront.utils;

import com.wavefront.mtl.elements.Texture;

public class TextureUtils {

	private TextureUtils() {
	}

	private static TextureUtils instance = null;

	public static TextureUtils instance() {
		if (instance == null)
			instance = new TextureUtils();
		return instance;
	}

	public Texture[] loadAnimation(String path, int cols, int rows,
			int textWidth, int textHeight) {
		return loadAnimation(path, cols, rows, textWidth, textHeight, 0, 0);
	}

	private Texture[] loadAnimation(String path, int cols, int rows,
			int textWidth, int textHeight, int xOffSet, int yOffSet) {
		Texture[] toReturntextures = new Texture[cols * rows];

		for (int i = 0; i < rows; i++)
			for (int j = 0; j < cols; j++) {
				toReturntextures[i * cols + j] = loadTexture(path, j
						* textWidth + xOffSet, i * textHeight + yOffSet,
						textWidth, textHeight);
			}

		return toReturntextures;
	}

	public Texture loadTexture(String path) {
		return loadTexture(path, 0, 0, 0, 0);
	}

	private Texture loadTexture(String path, int xOffSet, int yOffSet,
			int textWidth, int textHeight) {
		Texture toReturn = null;
		// TODO Texture

		return toReturn;
	}
}
